package com.letv.whatslive.mongo.dao;

import com.letv.whatslive.model.OpMessage;
import com.letv.whatslive.model.convert.OpMessageConvert;
import com.letv.whatslive.mongo.BaseDAO;
import com.mongodb.DBObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

/**
 * Created by wangjian7 on 2016/10/25.
 */
@Repository
public class OpMessageDAO extends BaseDAO{
    private final static Logger logger = LoggerFactory.getLogger(OpMessageDAO.class);

    protected String collectionName = "opMessage";


    @Override
    protected void init() {
        super.init(this.collectionName);
    }

    @Override
    protected long getAutoIncrementId() {
        return idGenerate.generateId(this.collectionName);
    }

    public long insertOpMessage(OpMessage opMessage){
        DBObject obj = OpMessageConvert.castOpMessageToDBObject(opMessage);
        return this.insert(obj);
    }

}
